import http from '@/utils/http'

const BASE_URL = '/testing/apiCase'

export interface ApiCaseResp {
  id: string
  projectId: string
  moduleId: string
  name: string
  description: string
  level: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ApiCaseDetailResp {
  id: string
  projectId: string
  moduleId: string
  name: string
  description: string
  level: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ApiCaseQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface ApiCasePageQuery extends ApiCaseQuery, PageQuery {}

/** @desc 查询接口用例列表 */
export function listApiCase(query: ApiCasePageQuery) {
  return http.get<PageRes<ApiCaseResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询接口用例详情 */
export function getApiCase(id: string) {
  return http.get<ApiCaseDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增接口用例 */
export function addApiCase(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改接口用例 */
export function updateApiCase(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除接口用例 */
export function deleteApiCase(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出接口用例 */
export function exportApiCase(query: ApiCaseQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
